home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / KOOB / common / client / help.cs < prev    next >
Text File  |  2005-11-23  |  2KB  |  75 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Engine
  3. // 
  4. // Copyright (C) GarageGames.com, Inc.
  5. //-----------------------------------------------------------------------------
  6.  
  7. function HelpDlg::onWake(%this)
  8. {
  9.    HelpFileList.entryCount = 0;
  10.    HelpFileList.clear();
  11.    for(%file = findFirstFile("*.hfl"); %file !$= ""; %file = findNextFile("*.hfl"))
  12.    {
  13.       HelpFileList.fileName[HelpFileList.entryCount] = %file;
  14.       HelpFileList.addRow(HelpFileList.entryCount, fileBase(%file));
  15.       HelpFileList.entryCount++;
  16.    }
  17.    HelpFileList.sortNumerical(0);
  18.    for(%i = 0; %i < HelpFileList.entryCount; %i++)
  19.    {
  20.       %rowId = HelpFileList.getRowId(%i);
  21.       %text = HelpFileList.getRowTextById(%rowId);
  22.       %text = %i + 1 @ ". " @ restWords(%text);
  23.       HelpFileList.setRowById(%rowId, %text);
  24.    }
  25.    HelpFileList.setSelectedRow(0);
  26. }
  27.  
  28. function HelpFileList::onSelect(%this, %row)
  29. {
  30.    %fo = new FileObject();
  31.    %fo.openForRead(%this.fileName[%row]);
  32.    %text = "";
  33.    while(!%fo.isEOF())
  34.       %text = %text @ %fo.readLine() @ "\n";
  35.  
  36.    %fo.delete();
  37.    HelpText.setText(%text);
  38. }
  39.  
  40. function getHelp(%helpName)
  41. {
  42.    Canvas.pushDialog(HelpDlg);
  43.    if(%helpName !$= "")
  44.    {
  45.       %index = HelpFileList.findTextIndex(%helpName);
  46.       HelpFileList.setSelectedRow(%index);
  47.    }
  48. }
  49.  
  50. function contextHelp()
  51. {
  52.    for(%i = 0; %i < Canvas.getCount(); %i++)
  53.    {
  54.       if(Canvas.getObject(%i).getName() $= HelpDlg)
  55.       {
  56.          Canvas.popDialog(HelpDlg);
  57.          return;
  58.       }
  59.    }
  60.    %content = Canvas.getContent();
  61.    %helpPage = %content.getHelpPage();
  62.    getHelp(%helpPage);
  63. }
  64.  
  65. function GuiControl::getHelpPage(%this)
  66. {
  67.    return %this.helpPage;
  68. }
  69.  
  70. function GuiMLTextCtrl::onURL(%this, %url)
  71. {
  72.    gotoWebPage( %url );
  73. }   
  74.  
  75.